/**
 * 2.1 数组解构
 */
// 传统声明多个变量
let a = 1;
let b = 2;
let c = 3;
console.log(a, b, c);
// es6
let [a1, b1, c1] = [2, 3, 4];
console.log(a1, b1, c1);
// undefined  null区别，undefined：表示为空，赋值为默认值；null表示'null'字符串
let [u='u', n='n'] = [undefined, null]
console.log(u, n);

/**
 * 2.2 对象解构
 * 数据是由位置决定值；对象是由变量名决定值，若变量名不一致则报错
 */
let {name, age} = {name: 'Maple', age: 29};
console.log(name, age);
// 坑点...
let foo;
({foo} = {foo: 'Maple'}); // 此处注意，一点要加上“( )”
console.log(foo);

/**
 * 2.3 字符串解构
 */
const [a2, b2, c2, d2, e2] = 'Maple';
console.log(a2, b2, c2, d2, e2)